home *** CD-ROM | disk | FTP | other *** search
- #ifndef __CHUNK_H__
- #define __CHUNK_H__
- /*
- * $RCSfile: chunk.h,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:19 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- typedef struct ChunkPage CHUNKPAGE;
-
- /*
- * Definition of a chunk descriptor.
- * Each chunk descriptor has three parts:
- * 1) the descriptor proper, which contains general information
- * about the chunk.
- * 2) a list of chunk user descriptors, where each user descriptor
- * contains information about the user that is accessing the chunk.
- * 3) a page descriptor, which contains information about the pages in
- * the chunk.
- *
- * We begin by defining what the chunk user descriptors look like.
- * There will be one chunk descriptor for each user accessing the chunk.
- *
- * When describing pages in a versioned large object, the term "shared"
- * will often be used. A shared page is one in which for some pointer
- * on the path to the page from the root node of the object the
- * share flag is set.
- */
-
- typedef struct {
-
- TWO type; /* indicates this is type chunk */
- TWO flags; /* status flag for chunk */
- char *basePtr; /* base pointer for accessing chunk */
- int byteCount; /* bytes accessible to user */
- char *bufFrame; /* actual beginning of chunk */
- int totalLength; /* total bytes that are in the chunk */
- BUFGROUP *bufGroup; /* buffer group user is working in */
- TWO firstPage; /* page descriptor index of first page */
- TWO pageCount; /* page descriptors that are valid */
- TWO descCount; /* number of allocated page descriptors */
- TWO dirtyPages; /* number of dirty pages in the chunk */
- TWO bufCount; /* number of buffers in chunk */
- TWO sharedPages; /* indicates number of shared pages */
- SLOTINDEX objectSlot; /* the slot of the object being accessed*/
- int bufIndex; /* index of the first buffer */
- PAGE2SIZE buf2size; /* number of buffers in chunk */
- int firstOffset; /* offset in first page of first user byte */
- LISTELEMENT memberList; /* hangs off the group/freelist struct */
- CHUNKPAGE *chunkPage; /* array of page descriptors */
- USERDESC *userDesc; /* a pointer to the user descriptor */
- BUFINFO *bufInfo;
- FID fid;
- PID rootPid;
- SLOTINDEX rootSlot; /* set to slot is root on slotted page*/
-
- #if MAGIC_CHECKING IS_ENABLED
-
- MAGIC magic; /* magic number for debugging */
-
- #endif
-
-
- } CHUNKDESC;
-
- /*
- * Define chunk state flags
- */
- #define CHUNK_INVALID 0x0 /* Chunk is not valid */
- #define CHUNK_VALID 0x1 /* Chunk contains valid data */
- #define CHUNK_USED 0x2 /* CHUNK_VALID & in a buffer group */
- #define CHUNK_FIXED 0x4 /* CHUNK_VALID & CHUNK_USED and */
- /* fixed in a buffer group */
- #define CHUNK_DIRTY 0x8 /* CHUNK_VALID and a page is dirty */
-
-
- #define CHUNK_IS_DIRTY(_chunkDesc) \
- ((_chunkDesc)->flags & CHUNK_DIRTY)
-
- #define DIRTY_CHUNK(_chunkDesc) \
- (_chunkDesc)->flags |= CHUNK_DIRTY
-
- #define CLEAN_CHUNK(_chunkDesc) \
- (_chunkDesc)->flags &= (~CHUNK_DIRTY)
-
- #define CHUNK_IS_USED(_chunkDesc) \
- ((_chunkDesc)->flags & CHUNK_USED)
-
- #define CHUNK_IS_FREE(_chunkDesc) \
- (!((_chunkDesc)->flags & CHUNK_USED))
-
- #define CHUNK_IS_VALID(_chunkDesc) \
- ((_chunkDesc)->flags & CHUNK_VALID)
-
- /*
- * define the magic number for chunk descriptors
- */
- #define CHUNKDESC_MAGIC 0x6d2b90c1
-
-
- /*
- * The page information structure that
- * keeps track of pages with chunks
- */
- struct ChunkPage {
-
- TWO flags;
- SLOTINDEX slot;
- int size;
- int offset;
- PID pid;
- BOOL shared; /* marks page shared by another verison */
- PAGEHASH *pageHash;
- CHUNKDESC *chunkDesc;
- GROUPLINK *nodeLink;
- LISTELEMENT hashList;
- SHORTPID parentPid;
- SLOTINDEX parentSlot;
- };
-
- #define PAGE_INVALID 0x0
- #define PAGE_VALID 0x1
- #define PAGE_DIRTY 0x2
-
-
- /*
- * Definition for the BufTable.
- * The BufTable is an array that describes how each buffer frame is being used.
- * If a frame is marked as valid and contains chunk data, then the
- * chunkDesc field will be non-NULL and will point to the chunk's descriptor.
- * If a frame is marked as valid and contains a slotted page, then the
- * hashPtr field will be non-NULL and will point to the page's hash entry.
- *
- * When a frame is in the pool of free frames (i.e., it is part of the
- * free list), the the frame is tagged as free, and the fields size,
- * nextBuf, prevBuf, and firstInBlk are set accordingly to link the
- * frame into the free list.
- *
- * Note that in a free block, the fields free and firstInBlk are set for
- * each buffer of the free block, whereas, the fields size, freeBlk,
- * and numClean are set in just the first buffer of the free block.
- */
- typedef struct BufInfo {
-
- ONE type;
- TWO index;
- char *blockInfo;
-
- };
-
-
- /*
- * Definitions for IO dependencies.
- * There are two types of IO dependencies.
- * - page dependencies of the form slotted page depends on slotted page.
- * - chunk dependencies of the form slotted page depends on chunk.
- *
- * If the dependency is a page dependency, then the pid field
- * will be non-NULL and will contain the page's pid.
- * If the dependency is a chunk dependency, then the chunkDesc field
- * will be non-NULL and will point to the chunk's descriptor.
- */
- typedef struct dependency {
-
- PID pid; /* page dependency */
- CHUNKDESC *chunkDesc; /* chunk dependency */
- struct dependency *nextDep; /* the next dependency */
-
- } DEPENDENCY;
-
- #endif __CHUNK_H__
-